<template>
	<view class="container pbsafe_80">
		<view class="height_78 fx fx_col jcc plr_12" style="background: #F08519;"
			v-if="(dataInfo.orderStatus==2 && orderType==1)||dataInfo.orderStatus==5">
			<view class="fx aic fz_16 fc_fff">
				<!-- <image class="width_32 height_32" :src="statusDir[dataInfo.orderStatus].icon||''" mode=""></image> -->
				<text>{{(dataInfo.payType==2&&dataInfo.orderStatus==5)?'待支付定金':dataInfo.orderStatusStr?dataInfo.orderStatusStr:statusDir[dataInfo.orderStatus].title}}</text>
			</view>
			<view class="mt_12 fc_fff fx aic" v-if="countdown">
				<u-count-down :time="countdown" :format="$utils.getCountdownformat(countdown)"
					@change="onChangeCountdown"></u-count-down>
				<text>后自动关闭</text>
			</view>
		</view>

		<view class="fc height_78 " style="background: #F08519;" v-else>
			<view class="fx aic jcc fz_16 fc_fff h100 pr">
				<image class="width_32 height_32" :src="require('@/static/images/order_icon2.png')" mode=""
					v-if="dataInfo.orderType == 6 && dataInfo.orderStatusStr == '待发货'"></image>
				<image class="width_32 height_32" :src="statusDir[dataInfo.orderStatus].icon||''" mode="" v-else>
				</image>

				<text v-if="dataInfo.orderStatus==12">交易完成</text>
				<text v-else
					class="ml_8">{{dataInfo.orderStatusStr?dataInfo.orderStatusStr:statusDir[dataInfo.orderStatus].title}}</text>
				<view class="pa b_4 fz_14 fc_fff"
					v-if="dataInfo.orderStatus==2&&dataInfo.auditPass==false&&orderType!=1">
					审核拒绝 {{dataInfo.auditRemark||''}}
				</view>

				<view class="fc_fff fz_14" v-if="dataInfo.orderStatus==12&&dataInfo.orderType!=6"
					style="position:absolute; bottom:10rpx; text-align:center;">
					评价商品可有机会转换积分~
				</view>
			</view>
		</view>
		<AddressInfo :arrow="false" :data="addressData" :extraData="(userType>4) ? dataInfo : null" />
		<view class="mt_8 ptb_8 plr_12 bc_fff" v-if="dataInfo.orderType!=6">
			<view class="p_4 fx aic jcb">
				<view>
					配送方式
				</view>
				<view class="fc_999">
					{{dataInfo.deliveryWay==1?'自提':'物流'}}
				</view>
			</view>
			<view class="p_4 fx aic jcb" v-if="dataInfo.deliveryWay==2">
				<view>
					物流方式
				</view>
				<view class="fc_999">
					{{dataInfo.logisticsDelivery==1?'平台物流':'指定物流'}}
				</view>
			</view>
			<view class="p_4 fx aic jcb" v-if="dataInfo.deliveryWay==2&&dataInfo.logisticsDelivery==1">
				<view>
					小区类型
				</view>
				<view class="fc_999">
					{{dataInfo.villageType==1?'电梯':`楼梯(${dataInfo.floorNumber||0}楼)`}}
				</view>
			</view>
			<view class="p_4 fx aic jcb" v-if="dataInfo.deliveryWay==2&&dataInfo.logisticsDelivery==1">
				<view>
					是否需要安装
				</view>
				<view class="fc_999">
					{{dataInfo.isInstall?'是':'否'}}
				</view>
			</view>
			<view class="p_4 fx aic jcb" v-if="!isSingleGoods">
				<view>
					是否一起发货
				</view>
				<view class="fc_999">
					{{dataInfo.isSendTogether?'是':'否'}}
				</view>
			</view>
		</view>
		<view style="display: flex;background-color: #fff;">
			<view class="mt_8 ptb_12 plr_16 bc_fff bob_1 boc_grey" style="min-width: 65%;">
				共{{dataInfo.productCount||0}}件商品
			</view>
			<view class="mt_8 ptb_12 plr_16 bc_fff bob_1 boc_grey" style="color: red;" v-if="dataInfo.orderType==7">
				抽奖订单</view>
		</view>


		<view class="bc_fff plr_16 pb_12" v-if="dataInfo.orderBrandInfoList&&dataInfo.orderBrandInfoList.length">
			<view class="" v-for="item,index in dataInfo.orderBrandInfoList" :key="index">
				<view class="fx aic bob_1 boc_grey ptb_12">
					<uni-icons custom-prefix="iconfont" type="icon-shangdian" color="#999" size="32rpx"></uni-icons>
					<view class="ml_4">
						{{item.brandName||''}}
					</view>
				</view>
				<template v-for="item1,index1 in item.productInfoList">
					<OrderItem type="2" :goodsType="goodsType" :orderType="orderType" :orderData="dataInfo"
						:data="item1" :key="index1" :isSingleDetail="isSingle" @cancel="handleCancel"
						@evaluate="handleEvaluate" @aftersale="handleAftersale" @check="handleCheck"
						@upload="handleUploadLog" @confirm="handleConfirm" />
					<view class="tb w100 mt_8" :key="index1">
						<view class="tbc width_80">
							购买留言
						</view>
						<view class="tbc fc_999 fr">
							{{item1.mark||''}}
						</view>
					</view>
				</template>
			</view>
		</view>


		<button class="mt_8 block_btn" open-type="contact">
			<view class="height_44 bc_fff fx aic jcc fz_14">
				<uni-icons custom-prefix="iconfont" type="icon-kefu" size="32rpx"></uni-icons>
				<view class="ml_4">
					联系客服
				</view>
			</view>
		</button>
		<view class="mt_8 pt_8 pb_16 plr_12 bc_fff">
			<view class="p_4 fx aic jcb p_4">
				<view>
					订单编号
				</view>
				<view class="fc_999 fx aic ">
					{{dataInfo.orderNo||''}}
					<button class="custom_btn default width_40 lh_21 br_2 ml_15 fz_12"
						style="border-color: #D3D3D3;color:#666" @click="handleCopy(dataInfo.orderNo)">复制</button>
				</view>
			</view>
			<template v-if="userType==9">
				<view class="p_4 fx aic jcb p_4" v-if="dataInfo.expectedReceiveTime">
					<view>
						期望收货时间
					</view>
					<view class="fc_999">
						{{dataInfo.expectedReceiveTime||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb" v-if="dataInfo.logisticsCompany">
					<view>
						物流平台
					</view>
					<view class="fc_999">
						{{dataInfo.logisticsCompany||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb" v-if="dataInfo.logisticsNo">
					<view>
						物流单号
					</view>
					<view class="fc_999 fx aic ">
						{{dataInfo.logisticsNo||''}}
						<button class="custom_btn default width_40 lh_21 br_2 ml_15 fz_12"
							style="border-color: #D3D3D3;color:#666"
							@click="handleCopy(dataInfo.logisticsNo)">复制</button>
					</view>
				</view>
			</template>
			<template v-else>
				<view class="p_4 fx aic jcb p_4">
					<view>
						下单时间
					</view>
					<view class="fc_999">
						{{dataInfo.createOrderTime||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb p_4" v-if="dataInfo.confirmTime">
					<view>
						确认时间
					</view>
					<view class="fc_999">
						{{dataInfo.confirmTime||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb p_4" v-if="dataInfo.payCertificateTime">
					<view>
						上传支付凭证时间
					</view>
					<view class="fc_999">
						{{dataInfo.payCertificateTime||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb p_4" v-if="dataInfo.finalPayCertificateTime">
					<view>
						上传尾款凭证时间
					</view>
					<view class="fc_999">
						{{dataInfo.finalPayCertificateTime||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb" v-if="dataInfo.logisticsCompany">
					<view>
						物流平台
					</view>
					<view class="fc_999">
						{{dataInfo.logisticsCompany||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb" v-if="dataInfo.logisticsNo">
					<view>
						物流单号
					</view>
					<view class="fc_999 fx aic ">
						{{dataInfo.logisticsNo||''}}
						<button class="custom_btn default width_40 lh_21 br_2 ml_15 fz_12"
							style="border-color: #D3D3D3;color:#666"
							@click="handleCopy(dataInfo.logisticsNo)">复制</button>
					</view>
				</view>
				<view class="p_4 fx aic jcb p_4" v-if="dataInfo.deliveryTime">
					<view>
						发货时间
					</view>
					<view class="fc_999">
						{{dataInfo.deliveryTime||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb p_4" v-if="dataInfo.completeTime">
					<view>
						完成时间
					</view>
					<view class="fc_999">
						{{dataInfo.completeTime||''}}
					</view>
				</view>
				<view class="p_4 fx aic jcb p_4" v-if="dataInfo.cancelTime">
					<view>
						取消时间
					</view>
					<view class="fc_999">
						{{dataInfo.cancelTime||''}}
					</view>
				</view>
				<template v-if="dataInfo.orderType!=6&&dataInfo.orderType!=7">
					<view class="p_4 fx aic jcb p_4">
						<view>
							订单金额
						</view>
						<view class="fc_999">
							￥{{dataInfo.totalPrice||0}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4">
						<view>
							优惠券
						</view>
						<view class="fc_999">
							-￥{{dataInfo.couponPrice||0}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4" v-if="dataInfo.orderStatus!=2">
						<view>
							平台优惠
						</view>
						<view class="fc_999">
							-￥{{dataInfo.salesDiscount||0}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4" v-if="dataInfo.youjiaDiscount&&appType!=base.ADMIN_TYPE">
						<view>
							金豆抵扣
						</view>
						<view class="fc_999">
							-￥{{dataInfo.youjiaDiscount||0}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4" v-if="dataInfo.deliveryWay==2">
						<view>
							合计配送费
						</view>
						<view class="fc_999">
							{{dataInfo.deliveryCost ? ('￥'+dataInfo.deliveryCost): (dataInfo.preOrderType == 5 ? '包邮' : '以线下门店为准')}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4"
						v-if="dataInfo.deliveryWay==2&&dataInfo.logisticsDelivery==1&&dataInfo.villageType==2">
						<view>
							合计上楼费
						</view>
						<view class="fc_999">
							{{dataInfo.upstairsCost ? ('￥'+dataInfo.upstairsCost): (dataInfo.preOrderType == 5 ? '包邮' : '以线下门店为准')}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4"
						v-if="dataInfo.deliveryWay==2&&dataInfo.logisticsDelivery==1&&dataInfo.isInstall">
						<view>
							合计安装费
						</view>
						<view class="fc_999">
							{{dataInfo.installCost ? ('￥'+dataInfo.installCost): (dataInfo.preOrderType == 5 ? '包邮' : '以线下门店为准')}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4" v-if="dataInfo.expectedReceiveTime">
						<view>
							期望收货时间
						</view>
						<view class="fc_999">
							{{dataInfo.expectedReceiveTime||''}}
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4" v-if="dataInfo.payCertificate && dataInfo.payCertificate.length">
						<view>
							{{dataInfo.payType==2?'定金':'支付'}}凭证
						</view>
						<view class="fc_primary"
							@click="certificateList=dataInfo.payCertificate;popupPreviewShow=true;">
							已上传，点击查看
						</view>
					</view>
					<view class="p_4 fx aic jcb p_4"
						v-if="dataInfo.finalPayCertificate && dataInfo.finalPayCertificate.length">
						<view>
							尾款凭证
						</view>
						<view class="fc_primary"
							@click="certificateList=dataInfo.finalPayCertificate;popupPreviewShow=true;">
							已上传，点击查看
						</view>
					</view>
				</template>
				<view class="bob_1 boc_grey mt_16"></view>
				<view class="mt_12 fx aic jce" v-if="dataInfo.orderType==6">
					实际支付：<text class="fc_zhured">{{dataInfo.integral||0}}积分+￥{{dataInfo.payAmount||0}}</text>
				</view>
				<template v-else>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus>6&&dataInfo.payType==1">
						已付款：<text class="fc_zhured">￥{{dataInfo.receivedAmount||0}}</text>
					</view>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus==6&&dataInfo.payType==1">
						已付金额：<text class="fc_zhured">￥{{dataInfo.actualAmount||0}}</text>
					</view>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus<=5&&dataInfo.payType==1">
						应付款：<text class="fc_zhured">￥{{dataInfo.actualAmount||0}}</text>
					</view>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus>=6&&dataInfo.payType==2">
						订单金额：<text class="fc_zhured">￥{{dataInfo.actualAmount||0}}</text>
					</view>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus<=5&&dataInfo.payType==2">
						待付全款：<text class="fc_zhured">￥{{dataInfo.actualAmount||0}}</text>
					</view>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus<=5&&dataInfo.payType==2">
						应付定金：<text class="fc_zhured">￥{{dataInfo.waitPayDeposit||0}}</text>
					</view>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus>=6&&dataInfo.payType==2">
						已付定金：<text class="fc_zhured">￥{{dataInfo.paidDeposit||0}}</text>
					</view>
					<view class="mt_12 fx aic jce"
						v-if="dataInfo.orderStatus>=6&&dataInfo.waitPayFinal&&dataInfo.payType==2">
						待付尾款：<text class="fc_zhured">￥{{dataInfo.waitPayFinal||0}}</text>
					</view>
					<view class="mt_12 fx aic jce" v-if="dataInfo.orderStatus>=9&&dataInfo.paidFinal&&dataInfo.payType==2">
						已付尾款：<text class="fc_zhured">￥{{dataInfo.paidFinal||0}}</text>
					</view>
				</template>
			</template>
		</view>
		<view class="pf b_0 l_0 r_0 pt_8 pbsafe_8 plr_12 fx fx_w jce bc_fff grid_8"
			v-if="dataInfo.orderType!=6&&dataInfo.orderType!=7">
			<navigator :hover-class="none" :url="`/pages/person/pages/receive?id=${id}&type=${orderType}`"
				v-if="$permis(dataInfo.orderStatus,'确认收款')">
				<button class="custom_btn primary lh_36 plr_12 br_40 fz_14">确认收款</button>
			</navigator>
			<button class="custom_btn default lh_36 plr_12 br_40 fz_14"
				v-if="$permis(dataInfo.orderStatus,'取消订单', isSingle)&&dataInfo.orderType!=7"
				@click="handleCancel()">取消订单</button>
			<!-- 			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" v-if="dataInfo.orderStatus==12&&isSingle"
				@click="handleEvaluate()">{{dataInfo.isReply==1?'查看评价':'评价'}}</button>
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" v-if="dataInfo.orderStatus==12&&isSingle"
				@click="handleAftersale()">{{dataInfo.afterSaleId?'查看售后':'售后'}}</button> -->
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14"
				v-if="$permis(dataInfo.orderStatus,'上传物流单',isSingle&&!dataInfo.logisticsImageUrl)&&((userType==2&&dataInfo.deliveryWay==1)||userType!=2)"
				@click="handleUploadLog()">上传物流单</button>
			<button class="custom_btn default lh_36 plr_12 br_40 fz_14" v-if="dataInfo.logisticsImageUrl"
				@click="handleCheck(dataInfo)">查看物流单</button>
			<button class="custom_btn default lh_36 plr_12 br_40 fz_14"
				v-if="$permis(dataInfo.orderStatus,'认购清单')&&dataInfo.orderType!=7"
				@click="handleCheckList">认购清单</button>
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" v-if="$permis(dataInfo.orderStatus,'上传支付凭证')"
				@click="handleUploadPayment">上传支付凭证</button>
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" v-if="$permis(dataInfo.orderStatus,'上传尾款凭证')"
				@click="handleUploadPayment">上传尾款凭证</button>
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" @click="handleConfirm()"
				v-if="$permis(dataInfo.orderStatus,'确认下单',orderType!=1||(orderType==1&&appType==base.ADMIN_TYPE))">确认下单</button>
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" @click="handleConfirm('goods')"
				v-if="$permis(dataInfo.orderStatus,'确认收货', isSingle)">确认收货</button>
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" @click="handleConfirm('install')"
				v-if="$permis(dataInfo.orderStatus,'确认安装', isSingle)">确认安装</button>
			<button class="custom_btn default lh_36 plr_12 br_40 fz_14" v-if="$permis(dataInfo.orderStatus,'删除记录')"
				@click="handleDelete">删除记录</button>
			<button class="custom_btn primary lh_36 plr_12 br_40 fz_14" @click="handleAudit"
				v-if="$permis(dataInfo.orderStatus,'立即审核',orderType!=1)">立即审核</button>
		</view>
		<PopupPreview key="pay" :title="(dataInfo.payType==2?'定金':'支付')+'凭证'" :list="certificateList"
			:visible.sync="popupPreviewShow" />
		<PopupPreview key="logistics" title="物流单" :list="logisticsImage" :visible.sync="popupPreviewLogisticsShow" />
		<PopupAuditOrder :data="dataInfo" :visible.sync="popupAuditOrderShow" @confirm="handleAuditOrder" />
		<PopupComfirmOrder :data="dataInfo" :visible.sync="popupConfirmOrderShow" @confirm="handleConfirmOrder" />
		<PopupComfirmRadarOrder :data="dataInfo" :visible.sync="popupConfirmRadarOrderShow"
			@confirm="handleConfirmRadarOrder" />
	</view>
</template>

<script>
	import AddressInfo from '@/components/goods/AddressInfo.vue'
	import OrderItem from '../components/OrderItem.vue'
	import PopupPreview from '@/components/PopupPreview.vue'
	import PopupComfirmOrder from '../components/PopupComfirmOrder.vue'
	import PopupComfirmRadarOrder from '../components/PopupComfirmRadarOrder.vue'
	import PopupAuditOrder from '../components/PopupAuditOrder.vue'
	import api from '@/service/config/api.js'
	import {
		mapState
	} from 'vuex'
	import {
		BASE
	} from '@/const/base.js'
	const statusDir = {
		1: {
			title: '待经销商确认',
			icon: require('@/static/images/order_icon1.png')
		},
		2: {
			title: '待确认',
			icon: require('@/static/images/order_icon1.png')
		},
		3: {
			title: '待主管审核',
			icon: require('@/static/images/order_icon1.png')
		},
		4: {
			title: '待总监审核',
			icon: require('@/static/images/order_icon1.png')
		},
		5: {
			title: '待付款',
			icon: require('@/static/images/order_icon1.png')
		},
		6: {
			title: '待确认收款',
			icon: require('@/static/images/order_icon1.png')
		},
		7: {
			title: '备货中',
			icon: require('@/static/images/order_icon1.png')
		},
		8: {
			title: '待支付尾款',
			icon: require('@/static/images/order_icon1.png')
		},
		9: {
			title: '待确认尾款',
			icon: require('@/static/images/order_icon1.png')
		},
		10: {
			title: '待收货',
			icon: require('@/static/images/order_icon2.png')
		},
		11: {
			title: '待安装',
			icon: require('@/static/images/order_icon1.png')
		},
		12: {
			title: '已完成',
			icon: require('@/static/images/order_icon4.png')
		},
		13: {
			title: '已取消',
			icon: require('@/static/images/order_icon3.png')
		},
	}
	// const timeArr = ['createOrderTime','','','','','','confirmTime','payCertificateTime','finalPayCertificateTime','deliveryTime','completeTime','cancelTime']
	export default {
		components: {
			AddressInfo,
			OrderItem,
			PopupPreview,
			PopupComfirmOrder,
			PopupComfirmRadarOrder,
			PopupAuditOrder
		},
		data() {
			return {
				base: BASE,
				id: '',
				statusDir,
				status: 0,
				popupPreviewShow: false,
				popupConfirmOrderShow: false,
				popupAuditOrderShow: false,
				popupConfirmRadarOrderShow: false,
				popupPreviewLogisticsShow: false,
				dataInfo: {},
				addressData: {},
				logisticsImage: [], // 物流单
				orderType: 1, // 1-普通 2-业务员 3-赚多多
				goodsType: 1,
				countdown: 0,
				certificateList: [],
			}
		},
		computed: {
			...mapState(['appType', 'userType']),
			totalNum() {
				if (this.dataInfo.orderBrandInfoList && this.dataInfo.orderBrandInfoList.length) {
					return this.dataInfo.orderBrandInfoList.reduce((num, item) => {
						return num + item.productInfoList.reduce((num1, item1) => {
							return num1 + item1.payNum * 1
						}, 0)
					}, 0)
				}
				return 0
			},
			// 是否单商品(判断是否一起发货)
			isSingle() {
				if (this.dataInfo.orderBrandInfoList && this.dataInfo.orderBrandInfoList.length) {
					let count = this.dataInfo.orderBrandInfoList.reduce((num, item) => {
						return num + item.productInfoList.length
					}, 0)
					return count <= 1 ? true : this.dataInfo.isSendTogether
				} else {
					return true
				}
			},
			// 是否单商品
			isSingleGoods() {
				if (this.dataInfo.orderBrandInfoList && this.dataInfo.orderBrandInfoList.length) {
					let count = this.dataInfo.orderBrandInfoList.reduce((num, item) => {
						return num + item.productInfoList.length
					}, 0)
					return count <= 1
				} else {
					return true
				}
			},
		},
		onLoad(options) {
			this.orderType = options.type || 1
			this.id = options.id
		},
		onShow() {
			if (this.id) {
				this.getData()
			} else {
				this.$utils.showToast('暂无此订单', 1500, 1)
			}
		},
		methods: {
			getData() {
				this.$utils.loading()
				api.get(((this.orderType == 2 ? '/order/api/order/detailGzt/' : '/order/api/order/detail/')) + this.id)
					.then(res => {
						res.data.payCertificate = res.data.payCertificate ? res.data.payCertificate.split(',') : []
						res.data.finalPayCertificate = res.data.finalPayCertificate ? res.data.finalPayCertificate
							.split(',') : []
						if (this.orderType == 2) {
							res.data.orderStatus = this.$utils.orderSysStatus2status(res.data.sysOrderStatus) || res
								.data.orderStatus
							res.data.orderStatusStr = res.data.sysOrderStatusStr
						}
						this.dataInfo = res.data
						this.countdown = res.data.countdown ? res.data.countdown * 1 : 0
						console.log(this.$moment.unix(res.data.countdown).format('DD天HH:mm:ss'))
						this.goodsType = res.data.orderType
						const {
							realName,
							userPhone: phone,
							userAddress: address
						} = res.data
						this.addressData = {
							realName,
							phone,
							address
						}
					})
			},
			// 上传支付凭证
			handleUploadPayment() {
				if (this.id) {
					let payAmount = null
					let certificateType = 1
					if (this.dataInfo.payType == 1) {
						payAmount = this.dataInfo.payAmount
					} else {
						if (this.dataInfo.orderStatus == 5) {
							payAmount = this.dataInfo.waitPayDeposit
						} else {
							payAmount = this.dataInfo.waitPayFinal
						}
					}
					if (this.dataInfo.payType == 1) {
						if (this.dataInfo.orderStatus == 5) {
							certificateType = 3
						} else {
							certificateType = 2
						}
					} else {
						if (this.dataInfo.orderStatus == 5)
							certificateType = 1
						if (this.dataInfo.orderStatus == 8 || this.dataInfo.orderStatus == 10)
							certificateType = 2
					}

					uni.navigateTo({
						url: `/pages/person/pages/upload?id=${this.id}&payType=${this.dataInfo.payType}&type=payment&certificateType=${certificateType}&payAmount=${payAmount||0}`
					})
				}
			},
			handleCancel(data) {
				let params = {}
				if (data && data.orderInfoId) {
					params = {
						orderInfoId: data.orderInfoId
					}
				} else {
					params = {
						orderId: this.id
					}
				}
				if (data && (this.dataInfo.orderStatus == 1 || this.dataInfo.orderStatus == 2 || this.dataInfo
						.orderStatus == 5)) {
					return this.$utils.showModal({
						content: '此时取消需整个订单一起取消，是否确认一起取消？',
					}).then(() => {
						if (this.dataInfo.procureOrderOrigin == 2 && this.appType == this.$base.ADMIN_TYPE) {
							this.$utils.showModal({
								content: '本订单为用户下单转单，请注意到经销商后台将用户下单取消',
								confirmText: '确认取消'
							}).then(() => {
								this.$utils.loading()
								api.get('/order/api/order/cancelByOrderId', {
									orderId: this.id,
								}).then(res => {
									this.$utils.showToast('取消下单成功')
									this.getData()
								})
							})
						} else {
							this.$utils.loading()
							api.get('/order/api/order/cancelByOrderId', {
								orderId: this.id
							}).then(res => {
								this.$utils.showToast('取消下单成功')
								this.getData()
							})
						}
					})
				}
				if (this.dataInfo.procureOrderOrigin == 2 && this.appType == this.$base.ADMIN_TYPE) {
					this.$utils.showModal({
						content: '本订单为用户下单转单，请注意到经销商后台将用户下单取消',
						confirmText: '确认取消'
					}).then(() => {
						this.$utils.loading()
						api.get('/order/api/order/cancelByOrderId', {
							orderId: this.id,
						}).then(res => {
							this.$utils.showToast('取消下单成功')
							this.getData()
						})
					})
				} else {
					this.$utils.showModal({
						content: '是否取消该订单？',
					}).then(() => {
						this.$utils.loading()
						api.get('/order/api/order/cancelByOrderId', params).then(res => {
							this.$utils.showToast('取消下单成功')
							this.getData()
						})
					})
				}

			},
			onChangeCountdown(e) {
				// this.countdown = e
			},
			handleCopy(data) {
				uni.setClipboardData({
					data, // data的值为你要复制的内容
					success: res => {
						uni.showToast({
							title: '复制成功'
						})
					}
				});
			},
			handleEvaluate(item) {
				let data = {}
				if (data) {
					data = item
				} else {
					data = this.dataInfo.orderBrandInfoList[0].productInfoList[0]
				}
				if (data.isReply == 1 && data.evaluateId) {
					uni.navigateTo({
						url: `/pages/person/pages/evaluate?e_id=${data.evaluateId}&o_id=${this.id}&g_id=${item.productId}&co_id=${data.orderInfoId}`
					})
				} else {
					uni.navigateTo({
						url: `/pages/person/pages/evaluate?o_id=${this.id}&g_id=${item.productId}&co_id=${data.orderInfoId}`
					})
				}
			},
			handleAftersale(item) {
				let data = {}
				if (data) {
					data = item
				} else {
					data = this.dataInfo.orderBrandInfoList[0].productInfoList[0]
				}
				if (data.afterSaleId) {
					uni.navigateTo({
						url: '/pages/person/pages/aftersale_detail?id=' + data.afterSaleId
					})
				} else {
					uni.navigateTo({
						url: `/pages/person/pages/aftersale?o_id=${this.id}&g_id=${item.productId}&co_id=${data.orderInfoId}`
					})
				}
			},
			handleCheck(item) {
				let data = item ? item : this.dataInfo.orderBrandInfoList[0].productInfoList[0]
				if (data.logisticsImageUrl) {
					this.logisticsImage = data.logisticsImageUrl.split(',')
					this.popupPreviewLogisticsShow = true
				} else {
					this.$utils.showToast('暂无物流单')
				}
			},
			// 确认订单
			handleConfirm(type, data) {
				let typeName = 'orderId'
				if (data) {
					typeName = 'orderInfoId'
				}
				let orderId = data ? data : this.id
				let receiptId = data ? data : this.id
				console.log('this.dataInfo.waitPayFinal', this.dataInfo.waitPayFinal)
				if (type == 'goods') {
					if (this.dataInfo.waitPayFinal) {
						this.handleUploadPayment()
						return
					}
					this.$utils.showModal({
						content: '确认收货吗？'
					}).then(() => {
						this.$utils.loading()
						api.get('/order/api/order/confirmReceipt', {
							[typeName]: receiptId
						}).then(res => {
							this.$utils.showToast('确认收货成功', 1500, 0, '', 'success')
							this.getData()
						})
					})
				} else if (type == 'install') {
					if (this.dataInfo.waitPayFinal) {
						this.handleUploadPayment()
						return
					}
					this.$utils.showModal({
						content: '确认安装吗？'
					}).then(() => {
						this.$utils.loading()
						api.get('/order/api/order/confirmInstall', {
							[typeName]: orderId
						}).then(res => {
							this.$utils.showToast('确认安装成功', 1500, 0, '', 'success')
							this.getData()
						})
					})
				} else if (type == 'receive') {
					this.$utils.showModal({
						content: '确认收款吗？'
					}).then(() => {
						this.$utils.loading()
						api.get('/order/api/order/confirmReceivedPayment', {
							orderId
						}).then(res => {
							this.$utils.showToast('确认收款成功', 1500, 0, '', 'success')
							this.getData()
						})
					})
				} else {
					if (this.orderType == 3) {
						this.popupConfirmRadarOrderShow = true
					} else {
						if (this.$store.state.userType == 3) {
							this.$utils.showModal({
								content: '确认下单吗？'
							}).then(() => {
								this.$utils.loading()
								api.get('/order/api/order/jxsConfirmOrder/' + this.id).then(res => {
									this.$utils.showToast('确认下单成功', 1500, 0, '', 'success')
									this.getData(true)
								})
							})
							return
						}
						this.popupConfirmOrderShow = true
					}
				}
			},
			handleDelete() {
				this.$utils.showModal({
					content: '是否删除该记录？',
				}).then(() => {
					this.$utils.loading()
					api.get('/order/api/order/delOrder/' + this.id).then(res => {
						this.$utils.showToast('删除记录成功', 1500, 1, '')
					})
				})
			},
			// 确认下单
			handleConfirmOrder(data, discount) {
				this.$utils.loading()
				api.post('/order/api/order/sysConfirmOrder', {
					orderId: this.id,
					salesDiscount: discount
				}).then(res => {
					this.$utils.showToast('下单成功', 1500, 0, '', 'success')
					this.popupConfirmOrderShow = false
					this.getData(true)
				})
			},
			// 赚多多订单-确认下单
			handleConfirmRadarOrder(data, params) {
				this.$utils.loading()
				api.post('/order/api/order/sysConfirmOrder', {
					orderId: this.id,
					...params
				}).then(res => {
					this.$utils.showToast('下单成功', 1500, 0, '', 'success')
					this.popupConfirmRadarOrderShow = false
					this.getData(true)
				})
			},
			handleAudit() {
				this.popupAuditOrderShow = true
			},
			// 审核
			handleAuditOrder(data, auditData) {
				this.$utils.loading()
				api.post('/order/api/order/audit', {
					orderId: this.id,
					isPass: auditData.isPass == 1 ? true : false,
					remark: auditData.remark
				}).then(res => {
					this.$utils.showToast('下单成功', 1500, 0, '', 'success')
					this.popupAuditOrderShow = false
					this.getData(true)
				})
			},
			handleUploadLog(data) {
				if (data) {
					uni.navigateTo({
						url: `/pages/person/pages/upload?infoId=${data.orderInfoId}&type=logistics`
					})
					return
				}
				uni.navigateTo({
					url: `/pages/person/pages/upload?id=${this.id}&type=logistics`
				})

			},
			// 认购清单
			handleCheckList() {
				uni.navigateTo({
					url: '/pages/person/pages/subscribe?id=' + this.id
				})
			}
		},
	}
</script>

<style lang="scss">
	.container {
		/deep/.u-count-down__text {
			color: #fff !important;
		}
	}
</style>